package com.example.android.viper;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

public class Splash extends Activity {
   
   private static final int STOPSPLASH = 0;
   //time in milliseconds
   private static final long SPLASHTIME = 0/*5000*/;
   
   private ImageView splash;
   public int screenHeight;
   public int screenWidth;
   
   //handler for splash screen
   private Handler splashHandler = new Handler() {
      /* (non-Javadoc)
       * @see android.os.Handler#handleMessage(android.os.Message)
       */
      @Override
      public void handleMessage(Message msg) {
         switch (msg.what) {
         case STOPSPLASH:
            //remove SplashScreen from view
            splash.setVisibility(View.GONE);
           //start a new activity
            Intent new_activity = new Intent(Splash.this, Home.class);
                                   
            startActivity(new_activity);
            finish();
            
                       
            break;
         }
         super.handleMessage(msg);
      }
   };
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        
        // Load Configuration File
        Config.Load();
               
        DisplayMetrics displaymetrics = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
        screenHeight = displaymetrics.heightPixels;
        screenWidth = displaymetrics.widthPixels;
	    //Log.d("ScreenSize", "screenHeight: " + Float.toString(screenHeight) + "\n screenWidth: " + Float.toString(screenWidth)); 
	   
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
	    setContentView(R.layout.intro);
	    splash = (ImageView) findViewById(R.id.imageView1);
	    Message msg = new Message();
	    msg.what = STOPSPLASH;
	    splashHandler.sendMessageDelayed(msg, SPLASHTIME);
    }
   
    
}
